{% extends '::base.html.twig' %}

{% block body %}
    <h1>{% trans %}global.forum{% endtrans %}</h1>
    <h2>{{ topic.name }}</h2>
    
    {% if app.user != null %}
        <a href="{{ path('MeestersForumBundle_PostNew', {'topicId': topic.id}) }}">Reageer</a>
    {% endif %}
        
    <ul>
        {% for post in topic.posts %}
            <li>
                <div>
                    <h5>{{ post.user.username }}</h5>
                    <img src="avatar" alt="{{ post.user.username }}" />
                </div>
                <div>
                    <p>{{ post.message }}</p>
                    <p>{{ post.time|date('Y-m-d H:i:s') }}</p>
                </div>
            </li>
        {% endfor %}
    </ul>

    <ul class="record_actions">
        <li>
            <a href="{{ path('MeestersForumBundle_ForumShow', {'id': topic.forum.id}) }}">
                Back to the list
            </a>
        </li>
        <li>
            <a href="{{ path('MeestersForumBundle_TopicEdit', { 'id': topic.id }) }}">
                {% trans %}global.button.edit{% endtrans %}
            </a>
        </li>
        <li>
            <form action="{{ path('MeestersForumBundle_TopicDelete', { 'id': topic.id }) }}" method="post">
                {{ form_widget(delete_form) }}
                <button type="submit">{% trans %}global.button.delete{% endtrans %}</button>
            </form>
        </li>
    </ul>
{% endblock %}